/*
 * al_record_list_manager.h
 *
 *  Created on: Aug 14, 2023
 *      Author: dk007
 */

#ifndef INCLUDE_AL_RECORD_LIST_MANAGER_H_
#define INCLUDE_AL_RECORD_LIST_MANAGER_H_

#include "stdint.h"
#include "al_storage_data_manager.h"

#define IDENTITY_CARD_UID_LEN   8
#define RECORD_INDEX_LEN        1
#include "al_app_svr_cmd.h"

struct node {
    uint8_t                 user_id[USER_ID_LEN];
    uint8_t                 key_id[KEY_ID_LEN];
    uint8_t                 uuid_uid_key[UUID_UID_KEY_LEN];
    uint8_t                 start_timestamp[TIMESTAMP_LEN];
    uint8_t                 end_timestamp[TIMESTAMP_LEN];
    struct  node            *next;
};

struct node *add_to_list(struct node *list, uint8_t *user_id, uint8_t *key_id, uint8_t *uuid_uid_key, uint8_t *start_timestamp, uint8_t *end_timestamp);
struct node *delete_from_list(struct node *list, uint8_t *uuid_uid_key);
struct node *search_list(struct node *list, uint8_t *uuid_uid_key);
struct node *search_list_by_user_id(struct node *list, uint8_t *user_id);
struct node *search_list_by_key_id(struct node *list, uint8_t *key_id);
void update_to_list(struct node *list, uint8_t *user_id, uint8_t *key_id, uint8_t *uuid_uid_key, uint8_t *start_timestamp, uint8_t *end_timestamp);
uint8_t get_list_all_record(struct node *list, uint8_t *data, uint16_t *data_len);
void list_mutex_init(void);

#endif /* INCLUDE_AL_RECORD_LIST_MANAGER_H_ */
